Aligning Text

Sometimes, you may want your text to be placed at a specific position on a Web page. For example, you may want to add a heading for the content present on a Web page, centrally aligned at the top of the page content. The text-align property allows you to horizontally align your text. You can also align your text vertically using the vertical-align property.

Let’s do the following steps to align the text present on an HTML Web page:


<!DOCTYPE html>
<html>
<head>
    <title>Aligning Text</title>
    <style type=”text/css”.
    h1 {text-align:left}
    h2 {text-align:center}
    h3 {text-align:right}
</style>
</head>
<body>
    <h1> This text is aligned to left.</h1>
    <h2> This text is aligned to center.</h2>
    <h3> This text is aligned to right.</h3>
</body>
</html>

Save the document with the name TextAligning.html and open on browser.